define(["jquery","vue","layer",'common'],function ($,Vue,layer,common) {
    const Controller = {
        index:function (){
            var app = Vue.createApp({
                data(){
                    return {
                        seachObj:[
                            {
                                field:"custom",
                                value:null
                            },
                            {
                                field:"isTree",
                                value:1
                            }
                        ],
                        dataObj:{
                            total:0,
                            rows:[],
                            limit:10,
                            page:1
                        }
                    }
                },
                created(){
                    this.indexLoadData()
                    this.indexCreateHeight(140)
                },
                methods:{
                    ...common,
                }
            })
            common.loadELEMENT(app,false)
            app.mount("#app");
        },
        add:function (){
            var app = Vue.createApp({
                data(){
                    return {
                        form:{
                            pid:[],
                            name:"",
                            rules:[],
                            status:1
                        },
                        allRules:[],
                        pidList:[]
                   }
                },
                created(){
                    this.loadRules()
                    this.getPids()
                },
                methods: {
                    ...common,
                    loadRules(){
                        let that = this
                        let url = 'auth.admin/get_rules';
                        this.moduleGet(url,{},function (res){
                            that.allRules = res.rows
                        })
                    },
                    getPids(){
                        let that = this
                        let url = 'auth.group/get_pids';
                        this.moduleGet(url,{},function (res){
                            that.pidList = res.rows
                        })
                    }
                }
            })
            common.loadELEMENT(app,false)
            
            app.mount("#app");
        },
        edit:function (){
            var app = Vue.createApp({
                data(){
                    return {
                        form:{
                            pid:[],
                            name:"",
                            rules:[],
                            status:1
                        },
                        allRules:[],
                        pidList:[]
                    }
                },
                created(){
                    this.loadRules()
                    this.getPids()
                    this.getEditData()
                    setTimeout(()=>{
                        console.log(this.form)
                    },1000)
                },
                methods: {
                    ...common,
                    loadRules(){
                        let that = this
                        let url = 'auth.admin/get_rules';
                        this.moduleGet(url,{},function (res){
                            that.allRules = res.rows
                        })
                    },
                    getPids(){
                        let that = this
                        let url = 'auth.group/get_pids';
                        this.moduleGet(url,{},function (res){
                            that.pidList = res.rows
                        })
                    }
                }
            })
            common.loadELEMENT(app)
            
            app.mount("#app");
        }
    }
    return Controller
});